package cn.bigcontainer.alt.calendar.dto;

import java.util.Map;

import cn.bigcontainer.alt.calendar.extension.MCalendarEventListProcessor;
import cn.bigcontainer.alt.common.entity.BigMap;
import cn.bigcontainer.alt.common.util.WoKit;
import cn.bigcontainer.alt.meta.dto.MAppDto;
import cn.bigcontainer.alt.meta.po.MApp;

/**
 * @author jiaod
 *
 */
public class MCalendar  extends MAppDto{

	public MCalendar(MApp app, BigMap<String, Object> req) {
		super(app);
		getObject().setRequest(req);
	}

	public MCalendar(MApp app) {
		super(app);
	}

	public MCalendar() {
		super();
	}
	
	public final static String PARAM_EXT_LIST_PROCESSOR = PREFIX_EXTENSION + "eventListProcessor";
	
	private MCalendarEventListProcessor eventListProcessor = null;

	/**
	 * @return
	 */
	private MCalendarEventListProcessor getExtensionEventListProcessor () {
		if (eventListProcessor != null) {
			return eventListProcessor;
		}
		String ex = getExtension(PARAM_EXT_LIST_PROCESSOR);
		if (WoKit.isEmpty(ex) || !WoKit.containsBean(ex)) {
			return eventListProcessor = WoKit.getBean(MCalendarEventListProcessor.class);
		}
		return eventListProcessor = WoKit.getBean(MCalendarEventListProcessor.class, ex);
	}
	
	/**
	 * @param event
	 * @param id
	 * @param subAppIds
	 * @param start
	 * @param end
	 * @param req
	 * @return
	 */
	public MCalendarEvent process (MCalendarEvent event, String id, String[] subAppIds, String start, String end,
			Map<String, Object> req) {
		return getExtensionEventListProcessor ().process(event, id, subAppIds, start, end, req);
	}
}
